package com.lqy.demo_one.common.lang;

import com.baomidou.mybatisplus.extension.api.R;
import lombok.Data;

import java.io.Serializable;

/**
 * @author: lqy
 * @date: 2021/10/8 10:56
 * @description:
 */
@Data
public class Result implements Serializable {
    //200正常，非200异常
    private  int code;
    private String msg;
    private Object data;

    public static Result success(Object data){
        return success(200,"ok",data);
    }

    public static Result success(int code,String msg,Object data){
        Result result = new Result();
        result.setCode(code);
        result.setData(data);
        result.setMsg(msg);
        return result;
    }

    public static Result failure(String msg){
        return failure(400,msg,null);

    }

    public static Result failure(String msg,Object data){
        return failure(400,msg,data);

    }

    public static Result failure(int code,String msg,Object data){
        Result result = new Result();
        result.setCode(code);
        result.setData(data);
        result.setMsg(msg);
        return result;

    }
}
